package com.kim.bookshop.book.serviceimpl;

import java.util.Date;
import java.util.List;

import com.kim.bookshop.book.bean.Book;
import com.kim.bookshop.book.bean.PageBean;
import com.kim.bookshop.book.dao.BookDao;
import com.kim.bookshop.book.service.BookService;
import com.kim.bookshop.category.bean.Category;

public class BookServiceImpl implements BookService{

	private BookDao bookDao;
	
	@Override
	public void save(Book book) {
		if(book!=null){
			bookDao.add(book);
		}
		
	}

	@Override
	public Book load(String bid) {
		return bookDao.findByBid(bid);
	}

	@Override
	public void remove(String bid) {
		bookDao.delete(bid);
		
	}

	@Override
	public void updateInfo(Book book) {
		bookDao.edit(book);
		
	}

	@Override
	public List<Book> findAll() {
		
		return bookDao.findAll();
	}

	@Override
	public List<Category> findCategorys() {
		return null;
	}

	@Override
	public List<Book> findByCategory(String cid) {
		return bookDao.findByCategory(cid);
	}

	public void setBookDao(BookDao bookDao) {
		this.bookDao = bookDao;
	}

	@Override
	public  List<Book> getStack() {
		return bookDao.getStack();
	}

	@Override
	public void updateStock(String bid, int count) {
		bookDao.updateStock(bid, count);
	}

	@Override
	public void cleanStock(String bid) {
		bookDao.cleanStock(bid);
		
	}

	@Override
	public List<Book> findOffLine() {
	
		return bookDao.getOffLine();
	}

	@Override
	public void reonline(String bid) {
		bookDao.reonline(bid);
		
	}

	@Override
	public PageBean<Book> searchBook(String bname) {
		 return bookDao.searchBook(bname);
	}

	@Override
	public PageBean<Book> findAllPage(int pc, int ps) {
		return bookDao.findAllPage(pc, ps);
	}

	@Override
	public List<Book> getPopList() {
		return bookDao.getPopBooks();
	}

	@Override
	public PageBean<Book> findByCategoryPage(String cid,int pc,int ps) {
		return bookDao.findByCategoryPage(cid, pc, ps);
	}

}
